package com.itheima.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller("aopAdvice")
@Aspect
public class AopAdvice {
    @Pointcut("execution(* *.*(..))")
    public void pt(){}

    @Around("pt()")
    public Object around(ProceedingJoinPoint pjp){
        System.out.println("前置运行。。。");

        try {
            Object proceed = pjp.proceed();
            System.out.println("返回运行。。。");
        } catch (Throwable throwable) {
            System.out.println("抛出异常。。。");
        } finally {
            System.out.println("后置运行。。。");
        }
        return null;
    }
}
